/**
 * 
 */
package com.xczhang.economize.db;



import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * @author xcz
 *
 */
public class DBHelper extends SQLiteOpenHelper {
	private static DBHelper dbhelper = null;
	private static String DATABASENAME="economize";
	
	public static DBHelper getInstance(Context ctx){
		if(dbhelper==null){
			dbhelper = new DBHelper(ctx);
		}
		return dbhelper;
	}
	
	private DBHelper(Context context){
		this(context,DATABASENAME,null,1);
	}

	/**
	 * @param context
	 * @param name
	 * @param factory
	 * @param version
	 */
	public DBHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
		
	}

	/* (non-Javadoc)
	 * @see android.database.sqlite.SQLiteOpenHelper#onCreate(android.database.sqlite.SQLiteDatabase)
	 */
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.beginTransaction();
		String sql="create table tbl_config(name varchar(20),value varchar(20),)";
		db.execSQL(sql);
		sql="create table tbl_record (uuid varchar(20),type varchar(20),account varchar(20),date varchar(50),about varchar(50),item varchar(20),address varchar(50),note varchar(500),amount float)";
		db.execSQL(sql);
		db.endTransaction();
		

	}

	/* (non-Javadoc)
	 * @see android.database.sqlite.SQLiteOpenHelper#onUpgrade(android.database.sqlite.SQLiteDatabase, int, int)
	 */
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
